package com.dgut.shopManage.entity.dto;

import java.util.Date;

import org.springframework.beans.BeanUtils;

import com.dgut.common.util.Xtype;
import com.dgut.shopManage.entity.Apply;
import com.dgut.shopManage.entity.Shop;
import com.fasterxml.jackson.annotation.JsonFormat;

public class ApplyDTO {
	private Long id;
	private String sName;   			//店铺名称
	private String mName;  				//租客名称
	private String tphone;				//联系方式
	private Xtype type;				//经营类型
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss",timezone = "GMT+8")
	private Date sTime;    				//租用开始时间
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss",timezone = "GMT+8")
	private Date eTime;					//租用结束时间
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss",timezone = "GMT+8")
	private Date aTime;					//申请时间
	
	private Long shopId;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getsName() {
		return sName;
	}
	public void setsName(String sName) {
		this.sName = sName;
	}
	public String getmName() {
		return mName;
	}
	public void setmName(String mName) {
		this.mName = mName;
	}
	public String getTphone() {
		return tphone;
	}
	public void setTphone(String tphone) {
		this.tphone = tphone;
	}
	public Xtype getType() {
		return type;
	}
	public void setType(Xtype type) {
		this.type = type;
	}
	public Date getsTime() {
		return sTime;
	}
	public void setsTime(Date sTime) {
		this.sTime = sTime;
	}
	public Date geteTime() {
		return eTime;
	}
	public void seteTime(Date eTime) {
		this.eTime = eTime;
	}
	public Date getaTime() {
		return aTime;
	}
	public void setaTime(Date aTime) {
		this.aTime = aTime;
	}
	public Long getShopId() {
		return shopId;
	}
	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}

	
	public static void dtoToEntity(ApplyDTO dto , Apply apply) {
		BeanUtils.copyProperties(dto, apply);

	}
	public static void entityToDto(Apply apply , ApplyDTO dto) {
		BeanUtils.copyProperties(apply, dto);
		Shop shop = apply.getShop();
		if(shop!=null) {
			dto.setShopId(shop.getId());//把关系传递到View
		}
	}
	@Override
	public String toString() {
		return "ApplyDTO [id=" + id + ", sName=" + sName + ", mName=" + mName + ", tphone=" + tphone + ", type=" + type
				+ ", sTime=" + sTime + ", eTime=" + eTime + ", aTime=" + aTime + 
				 ", shopId=" + shopId + "]";
	}
}
